<!-- 统计卡片 -->
<template>
  <el-row :gutter="15">
    <el-col :lg="6" :md="12">
      <el-card class="analysis-chart-card" shadow="never">
        <template v-slot:header>
          <div class="ele-cell">
            <div class="ele-cell-content">总充值数</div>
            <el-tag size="mini" type="primary" >今日</el-tag>
          </div>
        </template>
        <div class="analysis-chart-card-num ele-text-heading" style="padding-top: 0px"> {{saleData.day_in_count}}</div>
        <div class="analysis-chart-card-content" style="padding-top: 18px">
          <span class="ele-action">
            <span>昨日 {{ saleData.lastday_in_count }} </span>
          </span>
          <span class="ele-action">
            <span>日环比{{ saleData.in_count_rate }}%</span>
            <i :class="Number(saleData.in_count_rate) >= 0 ? 'el-icon-caret-top ele-text-danger' : 'el-icon-caret-bottom ele-text-success'"></i>
          </span>
        </div>
        <el-divider />
        <div class="total">
          <el-row>
            <el-col :span="12">
              本月充值点数
            </el-col>
            <el-col :span="12" class="ivu-text-right">
              {{saleData.month_in_count}}个
            </el-col>  
          </el-row>
        </div>
        
      </el-card>
    </el-col>
    <el-col :lg="6" :md="12">
      <el-card class="analysis-chart-card" shadow="never">
        <template v-slot:header>
          <div class="ele-cell">
            <div class="ele-cell-content">总支出数</div>
            <el-tag size="mini" type="primary" >今日</el-tag>
          </div>
        </template>
        <div class="analysis-chart-card-num ele-text-heading" style="padding-top: 0px"> {{saleData.day_out_count}}</div>
        <div class="analysis-chart-card-content" style="padding-top: 18px">
          <span class="ele-action">
            <span>昨日 {{ saleData.lastday_out_count }} </span>
          </span>
          <span class="ele-action">
            <span>日环比{{ saleData.out_count_rate }}%</span>
            <i :class="Number(saleData.out_count_rate) >= 0 ? 'el-icon-caret-top ele-text-danger' : 'el-icon-caret-bottom ele-text-success'"></i>
          </span>
        </div>
        <el-divider />
        <div class="total">
          <el-row>
            <el-col :span="12">
              本月支出点数
            </el-col>
            <el-col :span="12" class="ivu-text-right">
              {{saleData.month_out_count}}个
            </el-col>  
          </el-row>
        </div>
        
      </el-card>
    </el-col>
    <el-col :lg="6" :md="12">
      <el-card class="analysis-chart-card" shadow="never">
        <template v-slot:header>
          <div class="ele-cell">
            <div class="ele-cell-content">总开发者数</div>
            <el-tag size="mini" type="primary" >今日</el-tag>
          </div>
        </template>
        <div class="analysis-chart-card-num ele-text-heading" style="padding-top: 0px"> {{saleData.day_account_count}}</div>
        <div class="analysis-chart-card-content" style="padding-top: 18px">
          <span class="ele-action">
            <span>昨日 {{ saleData.lastday_account_count }} </span>
          </span>
          <span class="ele-action">
            <span>日环比{{ saleData.account_count_rate }}%</span>
            <i :class="Number(saleData.account_count_rate) >= 0 ? 'el-icon-caret-top ele-text-danger' : 'el-icon-caret-bottom ele-text-success'"></i>
          </span>
        </div>
        <el-divider />
        <div class="total">
          <el-row>
            <el-col :span="12">
              本月开发者数量
            </el-col>
            <el-col :span="12" class="ivu-text-right">
              {{saleData.month_account_count}}个
            </el-col>  
          </el-row>
        </div>
        
      </el-card>
    </el-col>
    <el-col :lg="6" :md="12">
      <el-card class="analysis-chart-card" shadow="never">
        <template v-slot:header>
          <div class="ele-cell">
            <div class="ele-cell-content">总平台数</div>
            <el-tag size="mini" type="primary" >今日</el-tag>
          </div>
        </template>
        <div class="analysis-chart-card-num ele-text-heading" style="padding-top: 0px"> {{saleData.day_open_count}}</div>
        <div class="analysis-chart-card-content" style="padding-top: 18px">
          <span class="ele-action">
            <span>昨日 {{ saleData.lastday_open_count }} </span>
          </span>
          <span class="ele-action">
            <span>日环比{{ saleData.open_count_rate }}%</span>
            <i :class="Number(saleData.open_count_rate) >= 0 ? 'el-icon-caret-top ele-text-danger' : 'el-icon-caret-bottom ele-text-success'"></i>
          </span>
        </div>
        <el-divider />
        <div class="total">
          <el-row>
            <el-col :span="12">
              本月平台数量
            </el-col>
            <el-col :span="12" class="ivu-text-right">
              {{saleData.month_open_count}}个
            </el-col>  
          </el-row>
        </div>
        
      </el-card>
    </el-col>
    
  </el-row>
</template>

<script>
  import { use } from 'echarts/core';
  import { CanvasRenderer } from 'echarts/renderers';
  import { LineChart, BarChart } from 'echarts/charts';
  import { GridComponent, TooltipComponent } from 'echarts/components';
  import VChart from 'vue-echarts';
  import { getAdminSaleData } from '@/api/dashboard/analysis';
  import { echartsMixin } from '@/utils/echarts-mixin';

  
 

  use([CanvasRenderer, LineChart, BarChart, GridComponent, TooltipComponent]);

  export default {
    name: 'StatisticsCard',
    components: { VChart },
    mixins: [echartsMixin(['visitChart', 'payNumChart'])],
    data() {
      return {
        // 访问量折线图配置
        visitChartOption: {},
        // 支付笔数柱状图配置
        payNumChartOption: {},
        saleData:{

          in_count:0,
          day_in_count:0,
          lastday_in_count:0,
          in_count_rate:0,
          month_in_count:0,


          out_count:0,
          day_out_count:0,
          lastday_out_count:0,
          out_count_rate:0,
          month_out_count:0,



          account_count:0,
          day_account_count:0,
          lastday_account_count:0,
          account_count_rate:0,
          month_account_count:0,


          open_count:0,
          day_open_count:0,
          lastday_open_count:0,
          open_count_rate:0,
          month_open_count:0,
        
        },
     

      };
    },
    created() {
      this.getPayNumData();
    },
    methods: {
      /* 获取数据 */
      getPayNumData() {
        
        getAdminSaleData()
          .then((data) => {
             this.saleData = data;

             this.visitChartOption = {
              color: '#975fe5',
              tooltip: {
                trigger: 'axis',
                formatter:
                  '<i class="ele-chart-dot" style="background: #975fe5;"></i>{b0}: {c0}'
              },
              grid: {
                top: 10,
                bottom: 0,
                left: 0,
                right: 0
              },
              xAxis: [
                {
                  show: false,
                  type: 'category',
                  boundaryGap: false,
                  data: data.date
                }
              ],
              yAxis: [
                {
                  show: false,
                  type: 'value',
                  splitLine: {
                    show: false
                  }
                }
              ],
              series: [
                {
                  type: 'line',
                  smooth: true,
                  symbol: 'none',
                  areaStyle: {
                    opacity: 0.5
                  },
                  data: data.account_value
                }
              ]
            };

            this.payNumChartOption = {
              tooltip: {
                trigger: 'axis',
                formatter:
                  '<i class="ele-chart-dot" style="background: #5b8ff9;"></i>{b0}: {c0}'
              },
              grid: {
                top: 10,
                bottom: 0,
                left: 0,
                right: 0
              },
              xAxis: [
                {
                  show: false,
                  type: 'category',
                  data: data.month
                }
              ],
              yAxis: [
                {
                  show: false,
                  type: 'value',
                  splitLine: {
                    show: false
                  }
                }
              ],
              series: [
                {
                  type: 'bar',
                  data:data.brokerage_value
                }
              ]
            };
        })
        .catch((e) => {
          this.$message.error(e.message);
        });

      }
    }
  };
</script>

<style lang="less" scoped>

  /deep/ .el-divider--horizontal {
    margin: 0 0 12px 0;
  }

  .total {
      font-size: 14px;
      font-weight: 400;
      color: #999;
      line-height: 22px;
  }

  .ivu-text-right {
    text-align: right;
  }

  .analysis-chart-card-num {
    font-size: 30px;
  }

  .analysis-chart-card-content {
    height: 40px;
    box-sizing: border-box;
    margin-bottom: 12px;
  }

  .analysis-chart-card-text {
    padding-top: 12px;
  }
</style>
